package com.example.drzhang.oengldemo.render;

import android.content.Context;
import android.opengl.GLES20;

import com.example.drzhang.oengldemo.util.TextResourceReader;

/**
 * Created by drzhang on 2018/1/10.
 */

public class ShaderProgram {
    //Uniform
    protected static final String U_MATRIX = "u_Matrix";
    protected static final String U_TEXTURE_UNIT = "u_TextureUnit";

    //attribute
    protected static final String A_POSITION = "a_Position";
    protected static final String A_COLOR = "a_Color";
    protected static final String A_TEXTURE_COORDINATES = "a_TextureCoordinates";

    protected int program;

    protected ShaderProgram(Context context, int vertexShaderResourceId, int fragmentShaderResourceId){
        program = ShaderHelper.buildProgram(
                TextResourceReader.readTextFileFromResource(context,vertexShaderResourceId),
                TextResourceReader.readTextFileFromResource(context,fragmentShaderResourceId)
        );
    }

    protected void userProgram(){
        GLES20.glUseProgram(program);
    }

}
